package librarianPanels;

import java.awt.Dimension;
import javax.swing.JPanel;
import clientGUI.MainGUI;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class ViewBookOrdersPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Create the panel.
	 */
	public ViewBookOrdersPanel() 
	{
		setPreferredSize(new Dimension(644, 462));
		setLayout(null);
		SearchABookPanel x = new SearchABookPanel();
		x.setLocation(0, 0);
		add(x);
		JButton btnNewButton = new JButton("View Orders");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(SearchABookPanel.table.getSelectedRow()!=-1)
				{
					String[] msgToServer=new String[2];
					msgToServer[0]="ViewBookOrders";
					msgToServer[1]=SearchABookPanel.table.getModel().getValueAt(SearchABookPanel.table.getSelectedRow(),0).toString();
					MainGUI.OBLClient.handleMessageFromClient(msgToServer);
				}
				else
					JOptionPane.showMessageDialog(new JFrame(),	"ERROR - Nothing selected!","Error",JOptionPane.ERROR_MESSAGE);

			}
		});
		btnNewButton.setBounds(419, 388, 142, 45);
		x.remove(x.background);
		x.add(btnNewButton);
		x.add(x.background);
	}
}
